package com.wy.panda.entity;

import java.io.Serializable;
import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wy.panda.common.bean.IPandaConverter;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * entity基类；
 * entity层只可与数据库中表结构映射，对象中不可添加对应表中不存在的属性
 *
 * @author WangYuan
 * @since 2020年7月30日 下午5:50:15
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode
public abstract class BaseEntity implements IPandaConverter, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6993395780304732630L;
	/**
	 * 删除标志位：0删除，1正常
	 */
	@TableLogic
	@TableField
	private Integer status;
	/**
	 * 创建者
	 */
	@TableField(fill = FieldFill.INSERT)
	private Long createdUser;
	/**
	 * 创建时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@TableField(insertStrategy = FieldStrategy.NOT_NULL, updateStrategy = FieldStrategy.NEVER, fill = FieldFill.INSERT)
	private Date createdTime;
	/**
	 * 修改者
	 */
	@TableField(fill = FieldFill.INSERT_UPDATE)
	private Long updatedUser;
	/**
	 * 修改时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@TableField(insertStrategy = FieldStrategy.NOT_NULL, updateStrategy = FieldStrategy.NOT_NULL, fill = FieldFill.INSERT_UPDATE)
	private Date updatedTime;
}
